﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YiYiTong.Rocket.DataAccess;
using YiYiTong.Rocket.EFDBFirst;
using YiYiTong.Rocket.Helper;

namespace YiYiTong.Rocket.Business
{
    public class ADZ_GoodsCategoryBiz
    {
        #region Instance
        private ADZ_GoodsCategoryBiz()
        {
        }
        private static ADZ_GoodsCategoryBiz _instance;

        private static object _syncObject = new object();

        public static ADZ_GoodsCategoryBiz Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (_syncObject)
                    {
                        if (_instance == null)
                        {
                            _instance = new ADZ_GoodsCategoryBiz();
                        }
                    }
                }
                return _instance;
            }
        }
        #endregion

        public List<ADZ_GoodsCategory> GetParentSunList()
        {
            List<ADZ_GoodsCategory> list = new List<ADZ_GoodsCategory>();
            DataTable dt = GoodsDataAccess.Instance.GetAllCategory();

            if (dt != null && dt.Rows.Count != 0)
            {
                //克隆原有数据表结构
                DataTable dtnew = dt.Clone();
                dtnew = Utils.GetDropItems(dt, dtnew, "category_name", "category_id", "0", "\u3000", "parent_id");
                list = new ModelHandler<ADZ_GoodsCategory>().FillModel(dtnew);
            }
            return list;
        }
    }
}
